<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    * {
        padding: 0;
        margin: 0;
    }

    .right {
        position: absolute;
        right: 0;
        height: 300px;
        width: 0;
        background-color: skyblue;
    }

    .a {
        width: 200px;
        transition: width 2s;
    }

    .b {
        width: 0;
        transition: width 2s;
    }
</style>

<body>
    <div id="app">
        <div class="right" v-bind:class="ClassStr"></div>
        <button v-on:click="handler(1)">点击</button>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
        let vm = new Vue({
            el: '#app',
            data: {
                value: 1,
                ClassStr: ''
            },
            methods: {
                handler(index) {
                    if (index == this.value) {
                        this.ClassStr = 'a'
                        this.value = 2
                    } else {
                        this.ClassStr = 'b'
                        this.value = 1
                    }
                }
            },
        })
    </script>
</body>

</html>